home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / circuits / spice2g6.z / spice2g6 / spice / Fortran / find.f < prev    next >
Encoding:
Text File  |  1989-02-03  |  6.0 KB  |  170 lines

  1.       subroutine find(aname,id,loc,iforce)
  2.       implicit double precision (a-h,o-z)
  3. c
  4. c     this routine searches the list with number 'id' for an element
  5. c with name 'aname'.  loc is set to point to the element.  if iforce is
  6. c nonzero, then find expects to have to add the element to the list, and
  7. c reports a fatal error if the element is found.  if subcircuit defini-
  8. c tion is in progress (nonzero value for nsbckt), then find searches the
  9. c current subcircuit definition list rather than the nominal element
  10. c list.
  11. c
  12. c spice version 2g.6  sccsid=tabinf 3/15/83
  13.       common /tabinf/ ielmnt,isbckt,nsbckt,iunsat,nunsat,itemps,numtem,
  14.      1   isens,nsens,ifour,nfour,ifield,icode,idelim,icolum,insize,
  15.      2   junode,lsbkpt,numbkp,iorder,jmnode,iur,iuc,ilc,ilr,numoff,isr,
  16.      3   nmoffc,iseq,iseq1,neqn,nodevs,ndiag,iswap,iequa,macins,lvnim1,
  17.      4   lx0,lvn,lynl,lyu,lyl,lx1,lx2,lx3,lx4,lx5,lx6,lx7,ld0,ld1,ltd,
  18.      5   imynl,imvn,lcvn,nsnod,nsmat,nsval,icnod,icmat,icval,
  19.      6   loutpt,lpol,lzer,irswpf,irswpr,icswpf,icswpr,irpt,jcpt,
  20.      7   irowno,jcolno,nttbr,nttar,lvntmp
  21. c spice version 2g.6  sccsid=cirdat 3/15/83
  22.       common /cirdat/ locate(50),jelcnt(50),nunods,ncnods,numnod,nstop,
  23.      1   nut,nlt,nxtrm,ndist,ntlin,ibr,numvs,numalt,numcyc
  24. c spice version 2g.6  sccsid=flags 3/15/83
  25.       common /flags/ iprnta,iprntl,iprntm,iprntn,iprnto,limtim,limpts,
  26.      1   lvlcod,lvltim,itl1,itl2,itl3,itl4,itl5,itl6,igoof,nogo,keof
  27. c spice version 2g.6  sccsid=memmgr 3/15/83
  28.       common /memmgr/ cpyknt,istack(1),lorg,icore,maxcor,maxuse,memavl,
  29.      1   ldval,numblk,loctab,ltab,ifwa,nwoff,ntab,maxmem,memerr,nwd4,
  30.      2   nwd8,nwd16
  31. c spice version 2g.6  sccsid=status 3/15/83
  32.       common /status/ omega,time,delta,delold(7),ag(7),vt,xni,egfet,
  33.      1   xmu,sfactr,mode,modedc,icalc,initf,method,iord,maxord,noncon,
  34.      2   iterno,itemno,nosolv,modac,ipiv,ivmflg,ipostp,iscrch,iofile
  35. c spice version 2g.6  sccsid=blank 3/15/83
  36.       common /blank/ value(200000)
  37.       integer nodplc(64)
  38.       complex cvalue(32)
  39.       equivalence (value(1),nodplc(1),cvalue(1))
  40. c
  41. c  index to the contents of the various lists:
  42. c
  43. c        list      contents
  44. c        ----      --------
  45. c
  46. c          1       resistors
  47. c          2       nonlinear capacitors
  48. c          3       nonlinear inductors
  49. c          4       mutual inductors
  50. c          5       nonlinear voltage controlled current sources
  51. c          6       nonlinear voltage controlled voltage sources
  52. c          7       nonlinear current controlled current sources
  53. c          8       nonlinear current controlled voltage sources
  54. c          9       independent voltage sources
  55. c         10       independent current sources
  56. c         11       diodes
  57. c         12       bipolar junction transistors
  58. c         13       junction field-effect transistors (jfets)
  59. c         14       metal-oxide-semiconductor junction fets (mosfets)
  60. c         15       s-parameter 2-port network
  61. c         16       y-parameter 2-port network
  62. c         17       transmission lines
  63. c         18       used for temperature sweeping
  64. c         19       subcircuit calls
  65. c         20       subcircuit definitions
  66. c         21       diode model
  67. c         22       bjt model
  68. c         23       jfet model
  69. c         24       mosfet model
  70. c      25-30       <unused>
  71. c         31       .print dc
  72. c         32       .print tran
  73. c         33       .print ac
  74. c         34       .print noise
  75. c         35       .print distortion
  76. c         36       .plot dc
  77. c         37       .plot tr
  78. c         38       .plot ac
  79. c         39       .plot noise
  80. c         40       .plot distortion
  81. c         41       outputs for dc
  82. c         42       outputs for transient
  83. c         43       outputs for ac
  84. c         44       outputs for noise
  85. c         45       outputs for distortion
  86. c      46-50       <unused>
  87. c
  88.       integer xxor
  89.       dimension lnod(50),lval(50)
  90.       data lnod /10,14,16, 8,15,16,15,16,13, 8,
  91.      1           18,38,27,35, 8, 8,35, 5, 5, 5,
  92.      2            5, 5, 5, 5, 0, 0, 0, 0, 0, 0,
  93.      3           21,21,21,21,21,21,21,21,21,21,
  94.      4            8, 8, 8, 8, 8, 0, 0, 0, 0, 0 /
  95.       data lval / 5, 4, 4, 2, 1, 1, 1, 1, 4, 4,
  96.      1            3, 4, 4,16, 1, 1, 9, 2, 1, 1,
  97.      2           19,55,17,46, 0, 0, 0, 0, 0, 0,
  98.      3            1, 1, 1, 1, 1,17,17,17,17,17,
  99.      4            1, 1, 1, 1, 1, 0, 0, 0, 0, 0 /
  100.       data ndefin /2h.u/
  101. c
  102. c
  103.       anam=aname
  104.       call sizmem(ielmnt,isize)
  105.       locn=ielmnt+isize+2
  106.       if (nsbckt.eq.0) go to 10
  107.       loct=nodplc(isbckt+nsbckt)
  108.       loc=nodplc(loct+3)
  109.       if (loc.ne.0) go to 20
  110.       nodplc(loct+3)=locn
  111.       go to 60
  112.    10 loc=locate(id)
  113.       if (loc.ne.0) go to 20
  114.       locate(id)=locn
  115.       go to 50
  116. c
  117. c  search list for a name match
  118. c
  119.    20 locv=nodplc(loc+1)
  120.       if (xxor(anam,value(locv)).ne.0) go to 30
  121.       if (numalt.ne.0) go to 30
  122.       if (nsbckt.eq.0) go to 25
  123.       if (nodplc(loc-1).ne.id) go to 30
  124.    25 if (nodplc(loc+2).eq.ndefin) go to 200
  125.       if (iforce.eq.0) go to 200
  126.       write (iofile,26) anam
  127.    26 format('0*error*:  above line attempts to redefine ',a8/)
  128.       nogo=1
  129.    30 if (nodplc(loc).eq.0) go to 40
  130.       loc=nodplc(loc)
  131.       go to 20
  132. c
  133. c  reserve space for this element
  134. c
  135.    40 nodplc(loc)=locn
  136.       if (nsbckt.ne.0) go to 60
  137.    50 if (numalt.eq.0) jelcnt(id)=jelcnt(id)+1
  138.    60 loc=locn
  139.       itemp=loc+lnod(id)*nwd4-1
  140.       locv=nxtevn(itemp-1)+1
  141.       itemp=locv-itemp
  142.       ktmp=lnod(id)*nwd4+lval(id)*nwd8+itemp
  143.       call extmem(ielmnt,ktmp)
  144.       locv=(locv-1)/nwd8+1
  145.       iptr=0
  146.       if (nsbckt.eq.0) go to 80
  147.       iptr=id
  148.    80 if (id.le.24) nodplc(loc+lnod(id)-2)=numalt
  149.       nodplc(loc-1)=iptr
  150.       nodplc(loc)=0
  151.       nodplc(loc+1)=locv
  152.       value(locv)=anam
  153. c
  154. c  background storage
  155. c
  156.   100 nodplc(loc+2)=ndefin
  157.       nword=lnod(id)-4
  158.       if (id.le.24) nword=nword-1
  159.       if (nword.lt.1) go to 120
  160.       call zero4(nodplc(loc+3),nword)
  161.   120 nword=lval(id)-1
  162.       if (nword.lt.1) go to 200
  163.       call zero8(value(locv+1),nword)
  164.       if ((id.ge.21).and.(id.le.24)) call undefi(value(locv+1),nword)
  165. c
  166. c  exit
  167. c
  168.   200 return
  169.       end
  170.